<template>
    <div class="history_pop" v-if="hisPopupShow">
        <div class="layer"></div>
        <div class="show_pop hislt">
            <div class="poptitle">
                <i @click="closeHisPopup"></i>
                <span class="fs14">历史</span>
            </div>
            <div class="contain">
                <table width="100%">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>是否自动保存</th>
                            <th>版本</th>
                            <th>结果</th>
                            <th>时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-if="historyList[0]" v-for="(item,index) in historyList" :key="index">
                            <td>{{index + 1}}</td>
                            <td>{{!!item.autoSave ? '自动' : '手动'}}</td>
                            <td>{{item.version}}</td>
                            <td>
                                <a class="zx-op_rem-btn" @click="viewVersion(item)">查看结果</a>
                            </td>
                            <td width="100">{{item.createTime | toDateTime}}</td>
                            <td>
                                <a class="zx-op_rem-btn" @click="recoverVersion(item)">恢复到该版本</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</template>

<script>
let self = null;
export default {
    name: "HistoryPop",
    data() {
        return {};
    },
    props: {
        hisPopupShow: {
            type: Boolean,
            default: false
        },
        historyList: {
            type: Array,
            default: () => []
        }
    },
    created(){
        self = this;
    },
    methods: {
        viewVersion(item) {
            this.$emit("viewVersion", item);
        },
        recoverVersion(item) {
            this.$emit("recoverVersion", item);
        },
        closeHisPopup(){
            this.$emit('closeHisPopup')
        }
    },
    filters: {
        toDateTime: function(_value) {
            // 时间转换器
            if (_value == undefined) return "--";
            return self.Utils.toDateTime(_value);
        }
    }
};
</script>

<style>
</style>
